'use strict';

angular.module('fbdApp.ruleModule')

.controller('ruleCtrl', function($scope, $filter) {

  $scope.modes = [{
    value: 1,
    content: '匹配开头'
  }, {
    value: 2,
    content: '匹配开头结尾'
  }, {
    value: 3,
    content: '匹配全文'
  }];

  if ($scope.ruleObj.type == undefined) {
    // $scope.ruleObj = {};
    $scope.ruleObj.type = '1';
  }
  if ($scope.ruleObj.similar == undefined) {
    $scope.ruleObj.similar = 1;
  }
  if ($scope.ruleObj.limit == undefined) {
    $scope.ruleObj.limit = 1;
  }

  $scope.$watch('ruleObj.beginText', function(v) {
    if (v != undefined) {
      $scope.ruleObj.beginText = $filter('ripContent')(v);
    }
  });

  $scope.$watch('ruleObj.endText', function(v) {
    if (v != undefined) {
      $scope.ruleObj.endText = $filter('ripContent')(v);
    }
  });

  // $scope.ruleObj = {};
  // modify situation
  // if ($scope.ruleData != undefined) {
  //   // console.log('modify');
  // }
  // // add situation
  // else {
  //   // console.log('add');
  //   $scope.ruleObj.type = '1';
  //   $scope.ruleObj.limit = 1;
  //   $scope.ruleObj.similar = 1;
  // }

  // $scope.tags = ['aaaa', 'bwbwbwbw', 'cccc'];


});
